local honghong = fk.CreateSkill {
  name = "cf_honghong",
}

Fk:loadTranslationTable {
  ["cf_honghong"] = "轰轰",
  [":cf_honghong"] = "1.一名角色的判定牌即将生效前你可以将其改为任意花色且点数为4。2.你的拼点牌点数视为【K】。",
  ["#cf_honghong-ask"] = "轰轰：你可以将判定结果 %arg 修改为任意花色，且点数视为4",
  ["$cf_honghong1"] = "可莉来帮忙。",
  ["$cf_honghong2"] = "锵锵，可莉登场！",
}

honghong:addEffect(fk.AskForRetrial, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(honghong.name)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local suit = room:askToChoice(player, {
      choices = { "Cancel", "log_spade", "log_heart", "log_club", "log_diamond" },
      skill_name = honghong.name,
      prompt = "#cf_honghong-ask:::" .. data.card:toLogString(),
      cancelable = true,
    })
    local choice
    if suit ~= "Cancel" then
      if suit == "log_spade" then
        choice = Card.Spade
      elseif suit == "log_heart" then
        choice = Card.Heart
      elseif suit == "log_club" then
        choice = Card.Club
      elseif suit == "log_diamond" then
        choice = Card.Diamond
      end
      event:setCostData(self, { suit = choice })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if data.card then
      local new_card = Fk:cloneCard(data.card.name, event:getCostData(self).suit, 4)
      new_card.skillName = honghong.name
      new_card.id = data.card.id
      data.card = new_card
      room:sendLog {
        type = "#ChangedJudge",
        from = player.id,
        to = { data.who.id },
        arg2 = new_card:toLogString(),
        arg = honghong.name,
      }
    end
  end,
})

honghong:addEffect(fk.PindianCardsDisplayed, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(honghong.name) and (player == data.from or data.results[player])
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    return room:askToSkillInvoke(player, { skill_name = honghong.name })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:changePindianNumber(data, player, 13, honghong.name)
  end,
})

return honghong
